package cn.jofei.common.thread;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledFuture;

/**
 * ScheduledJob
 *
 * @author Jofei Bao
 * @version ngbao v2.0
 * @date 2022年10月23日 15:45
 */
@Slf4j
public abstract class ScheduledJob implements Runnable {

    protected String taskName;

    public volatile ScheduledFuture<?> future;

    public void cancel() {
        if (future != null) {
            future.cancel(true);
            log.info("取消{}任务", taskName);
        }
    }
}
